import java.io.*;
import java.util.*;
public class Main{
    int n,k;
    int []x = new int[25];
    /*Main(){

    }*/
    int isPrime(int v){
        for(int i=2;i*i<=v;i++) if(v%i==0) return 0;
        return 1;
    }
    int dfs(int id,int cho,int sum){
        if(cho==k) return isPrime(sum);
        if(id==n) return 0;
        return dfs(id+1,cho,sum)+dfs(id+1,cho+1,sum+x[id+1]);
    }
    void work(){
        Scanner cin = new Scanner(System.in);
        n = cin.nextInt();
        k = cin.nextInt();
        for(int i=1;i<=n;i++) x[i] = cin.nextInt();
        System.out.println(dfs(0,0,0));
    }
    public static void main(String[]args){
        Main init = new Main();
        init.work();
    }
}